/* eslint-disable vue/html-indent */ /* eslint-disable vue/html-indent */
<template>
  <div class="cs-page-container">
    <div class="cs-filter-container">
      <el-select v-model="listQuery.channel" filterable clearable placeholder="渠道">
        <el-option
          v-for="(channel, i) in channels"
          :key="i"
          :label="channel"
          :value="channel"
        />
      </el-select>
      <el-select
        v-model="listQuery.bundleId"
        clearable
        placeholder="包名"
      >
        <el-option label="花伴交友app安卓" value="com.vchat.flower" />
        <el-option label="花伴交友app苹果" value="com.vchat.flower.ios" />
        <el-option label="花伴约会app安卓" value="com.date.flower" />
        <el-option label="花伴约会app苹果" value="com.date.flower.ios" />
        <el-option label="成人约会圈app安卓" value="com.chengren.yhq" />
        <el-option label="他趣附近约会app安卓" value="com.funnychat.mask" />
      </el-select>
      <el-date-picker
        v-model="daterangeValue"
        :picker-options="daterangePickerOptions"
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="起始时间"
        end-placeholder="结束时间"
        value-format="yyyy-MM-dd"
        clearable
        @change="daterangeChangedTimestamp"
      />
      <el-button
        type="primary"
        icon="el-icon-search"
        :loading="listLoading"
        @click="handleFilter"
      >
        查询
      </el-button>
      <el-button
        type="info"
        size="small"
        icon="el-icon-refresh-right"
        @click="resetFilter"
      >
        重置
      </el-button>
    </div>
    <div class="cs-filter-result">
      <el-table
        v-loading="listLoading"
        :data="list"
        border
        fit
        size="small"
        highlight-current-row
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        :height="'calc(100vh - 250px)'"
      >
        <el-table-column align="center" label="日期">
          <template slot-scope="{ row }">
            <span>{{
              (row.targetDate) | parseTime('{y}-{m}-{d}')
            }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户激活">
          <template slot-scope="{ row }">
            <span>{{ row.girlsActivateCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户登录">
          <template slot-scope="{ row }">
            <span>{{ row.girlsActiveCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户在线平均时长(分)">
          <template slot-scope="{ row }">
            <span>{{
              (
                row.girlsOnlineTimeTotal /
                row.girlsActiveCount /
                60
              ).toFixed()
            }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户app在线平均时长(分)">
          <template slot-scope="{ row }">
            <span>{{
              (
                row.girlsOnlineTimeTotalApp /
                row.girlsActiveCount /
                60
              ).toFixed()
            }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户视频总时长(分)">
          <template slot-scope="{ row }">
            <span>
              {{ (row.girlsVideoTimeTotal / 60).toFixed() }}
            </span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="女用户语音总时长(分)">
          <template slot-scope="{ row }">
            <span>{{ (row.girlsVoiceTimeTotal / 60).toFixed() }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="视频卡消耗">
          <template slot-scope="{ row }">
            <span>{{ row.tryCardCount }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="视频卡时长(分)">
          <template slot-scope="{ row }">
            <span>{{ (row.tryCardTimeTotal / 60).toFixed() }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="私聊券消耗">
          <template slot-scope="{ row }">
            <span>{{ row.chatTicketCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="求聊发布次数">
          <template slot-scope="{ row }">
            <span>{{ row.begChatCount }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="抢聊成功次数">
          <template slot-scope="{ row }">
            <span>{{ row.begChatGrapCount }}</span>
          </template>
        </el-table-column>
        <!--<el-table-column-->
        <!--align="center"-->
        <!--label="男用户打招呼次数"-->
        <!--&gt;-->
        <!--<template slot-scope="{row}">-->
        <!--<span>{{ row.boyHiCount }}</span>-->
        <!--</template>-->
        <!--</el-table-column>-->
        <el-table-column align="center" label="女用户打招呼次数">
          <template slot-scope="{ row }">
            <span>{{ row.girlHiCount }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="真人认证人数">
          <template slot-scope="{ row }">
            <span>{{ row.identificationCount }}</span>
          </template>
        </el-table-column>
      </el-table>
      <TablePagination
        :current-page="listQuery.page"
        :limit="listQuery.limit"
        :total="total"
        :loading="listLoading"
        @handleSizeChange="handleSizeChange"
        @handleCurrentChange="handleCurrentChangeOffset"
      />
    </div>
  </div>
</template>

<script>
  import TablePagination from '@/components/TablePagination'
  import DATEPICKER_OPTIONS from '@/config/datepickerOptions'
  import { xhrChatList } from '@/api/analysis'

  export default {
    name: 'ChatList',
    components: { TablePagination },
    data() {
      return {
        list: [],
        channels: [],
        total: 0,
        listQuery: {
          offset: 0,
          limit: 100,
          startTime: null,
          endTime: null,
          channel: null,
          bundleId: null,
          gender: null
        },
        daterangeValue: '',
        daterangePickerOptions: DATEPICKER_OPTIONS.daterangePickerOptions
      }
    },
    created() {
      this.getChannels()
      this.doSearch()
    },
    methods: {
      getChannels() {
        this.xhrGetChannels().then(resp => {
          this.channels = resp.data
        })
      },
      doSearch() {
        xhrChatList(this.listQuery).then(resp => {
          this.listLoading = false
          this.total = resp.data.count
          this.list = resp.data.list
        })
      }
    }
  }
</script>
